package cn.springcloud.fix.common.starter.event;

import cn.springcloud.fix.common.core.utils.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.bus.event.RemoteApplicationEvent;

@Slf4j
public class BaseEvent<T> extends RemoteApplicationEvent {

    private static final long serialVersionUID = 187180320877892048L;

    public BaseEvent(T source) {
        super(source, SpringUtil.getContext().getId());
    }

    public BaseEvent(T source, String destinationServiceId) {
        super(source, SpringUtil.getContext().getId(), destinationServiceId + ":**");
    }

    public void fire() {
        SpringUtil.publishEvent(this);
    }
}
